package com.fegin.Hystrix.admin;

import com.fegin.bean.admin.AdminUser;
import com.fegin.bean.common.layuiBean.ResultPage;
import com.fegin.bean.common.layuiBean.VoPage;
import com.fegin.client.admin.UserFegin;
import com.util.Respons.ResponseUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author 张子艺
 * @packge com.fegin.Hystrix
 * @data 2018-12-26 16:09
 * @project springCloud
 */
@Component
public class UserFigenHystrix implements FallbackFactory<UserFegin> {

    @Override
    public UserFegin create(Throwable throwable) {
        return new UserFegin() {
            @Override
            public AdminUser login(String userName, String passWord) {
                return new AdminUser();
            }

            @Override
            public ResultPage<AdminUser> findUser(VoPage voPage,Long loginId) {
                ResultPage<AdminUser> roleResultPage=new ResultPage<>();
                roleResultPage.setMsg("服务器繁忙，请刷新重试...");
                roleResultPage.setCode(1);
                return roleResultPage;
            }

            @Override
            public ResultPage<AdminUser> findDistributionPeoPleByPage(VoPage voPage) {
                ResultPage<AdminUser> roleResultPage=new ResultPage<>();
                roleResultPage.setMsg("服务器繁忙，请刷新重试...");
                roleResultPage.setCode(1);
                return roleResultPage;
            }

            @Override
            public Map<String, Object> insertUser(AdminUser user, Long roleId, Long loginId) {
                return ResponseUtil.getExceptionMap();
            }

            @Override
            public Map<String, Object> delUser(Long userId, String userName) {
                return ResponseUtil.getExceptionMap();
            }
        };
    }
}
